from commons.log import LogFactory
from service.message_service import text_msg, multi_msg, note_msg, map_msg, sharing_msg, card_msg

logger = LogFactory("message_action").get_logger()


def process_msg(msg, isGroup=False, isMp=False):
    """
    Text 文本，Content和Text是相同的内容，
    MAP 位置，
    CARD 个人名片
    NOTE 红包转账，消息撤回
    SHARING 收藏
    PICTURE 图片，用download保存下来
    RECORDING 语音
    ATTACHMENT 文件
    VIDEO 小视频
    FRIENDS 好友申请
    SYSTEM

    :param msg: 消息对象
    :param isGroup: 是否为群消息
    :return:
    """
    msg_type = msg.Type
    logger.debug("message type %s", msg_type)
    if msg_type == 'Text':
        text_msg(msg, isGroup)
    elif msg_type in ('Picture', 'Recording', 'Video', 'Attachment'):
        multi_msg(msg)
    elif msg_type == 'Note':
        note_msg(msg, isGroup=isGroup, isMp=isMp)
    elif msg_type == 'Map':
        map_msg(msg)
    elif msg_type == 'Sharing':
        sharing_msg(msg)
    elif msg_type == 'Card':
        card_msg(msg)
    else:  # System，点进群聊一定会触发一次
        pass
